<div class="container">
  <ol class="breadcrumb">
    <li><%= link_to 'Home', root_path %></li>
    <li class="active">Requests</li>
  </ol>
</div>

<div class="container">
  <h1>
    Listing requests
    <a href="<%= new_request_path %>" class="btn btn-success"> <span class="glyphicon glyphicon-upload"></span>
      Create new request</a>
  </h1>

  <% if @requests.empty? %>
      <p>

      <div class="alert alert-warning">
        Currently no requests are created with the system.
      </div>
      </p>
  <% else %>
      <div class="media">
        <table class="table table-hover">

          <thead>
          <tr>
            <th>#</th>
            <th>Organization</th>
            <th>Status</th>
            <th colspan="3"></th>
          </tr>
          </thead>

          <tbody>
          <% i = 1 %>
          <% @requests.each do |request| %>
              <tr>
                <td><%= i %></td>
                <td><%= request.title %></td>
                <td><%= request.status %></td>
                <% if request.status_id.to_s == ApplicationController::REQUEST_STATUS_PENDING %>
                    <td><%= link_to 'Remove', request_path(request), method: :delete, :class => "btn btn-xs btn-danger", data: {confirm: 'Are you sure?'} %></td>
                <% end %>
              </tr>
              <% i = i + 1 %>
          <% end %>
          </tbody>
        </table>
      </div>
  <% end %>
</div>
